﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.mNC.Calculate
{
    public class Cal_BatchQtyHelper
    {
        /// <summary>
        /// 获取图纸号和数量
        /// </summary>
        /// <param name="PartNo"></param>
        /// <param name="OrderNo"></param>
        /// <param name="strDWGNO"></param>
        /// <param name="douQTY"></param>
        public static void GetDwgAndQty(string PartNo, string OrderNo, out string strDWGNO, out int douQTY)
        {
            strDWGNO = "";
            douQTY = 0;
            DataTable dt = Common.GetDataTable.Get_OrderDataByDwgNo(PartNo, OrderNo);
            if (dt.Rows.Count > 0)
            {
                strDWGNO = dt.Rows[0]["Drawing_No"].ToString();
                douQTY = Convert.ToInt32(Convert.ToDouble(dt.Rows[0]["Part_QTY"].ToString()));
            }
        }
        /// <summary>
        /// 获取图纸号
        /// </summary>
        /// <param name="OrderNo">订单号</param>
        /// <param name="PartNo">物料号</param>
        public static void GetDwgNo(string OrderNo, string PartNo, out string strDWGNO)
        {

            strDWGNO = "";
            DataTable dt = Common.GetDataTable.Get_Part_Detailed_Dwg(OrderNo, PartNo);
            if (dt.Rows.Count > 0)
            {
                strDWGNO = dt.Rows[0]["Drawing_No"].ToString();
            }
        }
       
        public static void Get_BatchQty(string OrderNumber, string DWGNO, string PARTNO,int SUM_QTY, out int ZPL_QTY, out int ZWS_QTY, out int ZPL_COUNT)
        {
            ZPL_QTY = 0;
            ZWS_QTY = 0;
            ZPL_COUNT = 0;
            DataTable dt_Width = Common.GetDataTable.Get_FeatData_PartDetail(PARTNO, DWGNO, "H1");
            //DataTable dt_QTY = Common.GetDataTable.Get_FeatData_PartDetail_QTY(OrderNumber);


            if (dt_Width.Rows.Count > 0)
            {
                ZPL_QTY = Convert.ToInt32(Math.Floor(Convert.ToDecimal(300 / Convert.ToDecimal(dt_Width.Rows[0]["FACE_WIDTH"].ToString()))));
                //decimal Temp = Convert.ToDecimal(dt_QTY.Rows[0]["Part_QTY"].ToString());
                //ZWS_QTY = Temp - (Math.Floor(Temp / ZPL_QTY) * ZPL_QTY);
                ZPL_COUNT = SUM_QTY / ZPL_QTY;
                ZWS_QTY = SUM_QTY % ZPL_QTY;
            }
        }
    }
}
